-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding date filter to GetNodesCounts API #3586
Conversation
Signed-off-by: Lance Finfrock <[email protected]>
Signed-off-by: Lance Finfrock <[email protected]>
1cf00d2
to
1f808d9
Compare
Signed-off-by: Lance Finfrock <[email protected]>
…escount_date_filters
Signed-off-by: Lance Finfrock <[email protected]>
var ns = *new(backend.NodesCounts) | ||
|
||
// Adding the exists = true filter to the list of filters, because nodes | ||
// have documents that persist in elasticsearch to hold historical data | ||
// even after the node no longer exists | ||
filters["exists"] = []string{"true"} | ||
|
||
boolQuery := newBoolQueryFromFilters(filters) | ||
mainQuery := newBoolQueryFromFilters(filters) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the main change with this PR. The rest is passing the start and end date to this function.
@@ -461,13 +461,43 @@ func TestStatsNodesCountsWhen20Nodes(t *testing.T) { | |||
func TestStatsNodesCountsFilteringWithTableDriven(t *testing.T) { | |||
dataNodes := []struct { | |||
number int | |||
node iBackend.NodeInfo | |||
node iBackend.Node |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated this to be a node to allow for Checkin datetime variation.
🔩 Description: What code changed, and why?
Adding date filters to the GetNodesCounts allows a user to filter on nodes that have check-in between a specific period. This was added for the insight UI control for the Desktop view.
⛓️ Related Resources
#3372
👟 How to Build and Test the Change
build components/config-mgmt-service && build components/automate-gateway && start_all_services
for i in {1..5}; do generate_chef_run_example | jq --arg d $(date +%FT%TZ -d "$i day ago") '.end_time=$d' | send_chef_data_raw; done
curl -f --insecure -H "api-token: $(get_api_token)" --data-urlencode "start=$(date +%FT%TZ -d '3 day ago')" --data-urlencode "end=$(date +%FT%TZ -d '1 day ago')" https://localhost/api/v0/cfgmgmt/stats/node_counts | jq
✅ Checklist